const http = require('http')
const url = require('url')
const fs = require('fs')
const serve = http.createServer((request, response) => {
	const method = request.method
	const urldata = new URL(request.url, 'http://localhost:9000')
	response.setHeader('content-type', 'text/html;charset=utf-8')
	console.log(request.method, urldata.pathname)
	if (request.method === 'GET' && urldata.pathname === '/login') {
		const data = fs.readFileSync('login.html')
		response.end(data)
	} else if (request.method === 'GET' && urldata.pathname === '/register') {
		const data = fs.readFileSync('register.html')
		response.end(data)
	} else response.end('404 NotFound')
})
serve.listen(9000, () => {
	console.log('开始监听')
})